//
//  CYLMineViewController.m
//  CYLTabBarController
//
//  v1.21.x Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 10/20/15.
//  Copyright © 2018 https://github.com/ChenYilong . All rights reserved.
//

#import "CYLMineViewController.h"

#import <MJRefresh/MJRefresh.h>

//#import "AboutVc.h"
#import "Shebei_guanli_vc.h"
#import "XiaoxiTongzhi_vc.h"
#import "Zhanghaoanquan_vc.h"
#import "AppDelegate.h"

#import "QDCommonTableViewController.h"


@interface CYLMineViewController()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UIImageView *avatar_iv;

@property (weak, nonatomic) IBOutlet UILabel *name_lb;
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@end

@implementation CYLMineViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.avatar_iv sd_setImageWithURL:[NSURL URLWithString:AuthSignin_model.sharedInstance.data.user_info.avatar_url] placeholderImage:[UIImage imageNamed:@"mine_head_icon"]];
    [self.name_lb setText:AuthSignin_model.sharedInstance.data.user_info.nick_name];
}
#pragma mark - ®View lifecycle



- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    self.tableView.sectionHeaderHeight = .01;
    self.tableView.sectionFooterHeight = .01;
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    
    
    
    
  
 
    self.titleView.title = @"我的";
}
- (IBAction)quit_login_aciton:(UIButton *)sender {
    
    QMUIDialogViewController *dialogViewController = [[QMUIDialogViewController alloc] init];
    dialogViewController.title = @"退出登录";
    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 100)];
    contentView.backgroundColor = UIColorWhite;
    UILabel *label = [[UILabel alloc] qmui_initWithFont:UIFontMake(14) textColor:UIColorBlack];
    label.text = [NSString stringWithFormat:@"是否退出当前登录账户"];
    [label sizeToFit];
    label.center = CGPointMake(CGRectGetWidth(contentView.bounds) / 2.0, CGRectGetHeight(contentView.bounds) / 2.0);
    [contentView addSubview:label];
    dialogViewController.contentView = contentView;
    [dialogViewController addSubmitButtonWithText:@"确定" block:^(QMUIDialogViewController *aDialogViewController) {
        [aDialogViewController hide];
        
        [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"login_or_not"];
        AppDelegate *delegate = [UIApplication sharedApplication].delegate;
        [delegate ank_switch_to_loginVc];
    }];
    [dialogViewController addCancelButtonWithText:@"取消" block:nil];
    
    [dialogViewController show];
    return;
    
    //    MMPopupCompletionBlock btnBlock = ^(MMPopupView *popupView, BOOL finished){
    //
    //        DLog(@"%d", finished);
    //        if (finished) {
    //
    //            [[NSUserDefaults standardUserDefaults] setObject:@"" forKey:@"login_or_not"];
    //            AppDelegate *delegate = [UIApplication sharedApplication].delegate;
    //            [delegate ank_switch_to_loginVc];
    //
    //        }
    //    };
    //
    //    Tuichu_quren_popView *pinView = [Tuichu_quren_popView new];
    //    pinView.img_name = @"ad_remind_icon";
    //    pinView.tipStr = @"是否退出当前登录账户";
    //    pinView.btnBlock = btnBlock;
    //    [pinView show];
    
}

- (void)initSubviews{
    [super initSubviews];
    

  
    QMUIStaticTableViewCellDataSource *dataSource = [[QMUIStaticTableViewCellDataSource alloc] initWithCellDataSections:@[
        // section0
        @[
            // 一般情况下可以用 + 方法快速初始化一个 cellData
            [QMUIStaticTableViewCellData staticTableViewCellDataWithIdentifier:0
                                                                         image:UIImageMake(@"mine_aboutus_icon")
                                                                          text:@"消息中心"
                                                                    detailText:nil
                                                               didSelectTarget:self
                                                               didSelectAction:@selector(xiaoxi_zhongxin_event:)
                                                                 accessoryType:QMUIStaticTableViewCellAccessoryTypeDisclosureIndicator],
            // 嫌参数列表太长也可以这么写，没赋值的属性则使用默认值
            ({
        QMUIStaticTableViewCellData *d = [[QMUIStaticTableViewCellData alloc] init];
        d.identifier = 1;
        [d setStyle:UITableViewCellStyleValue1];
        d.text = @"关于我们";
        d.detailText = [NSString stringWithFormat:@"版本%@", [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"]];
        d.image = UIImageMake(@"mine_aboutus_icon");
        
        d.accessoryType = QMUIStaticTableViewCellAccessoryTypeNone;
        d;
    }),
            [QMUIStaticTableViewCellData staticTableViewCellDataWithIdentifier:2
                                                                         image:UIImageMake(@"mine_administration_icon")
                                                                          text:@"设备管理"
                                                                    detailText:nil
                                                               didSelectTarget:self
                                                               didSelectAction:@selector(shebei_guanli_event:)
                                                                 accessoryType:QMUIStaticTableViewCellAccessoryTypeDisclosureIndicator],
        ]
    ]];
    
    // 把数据塞给 tableView 即可
    self.tableView.qmui_staticCellDataSource = dataSource;
}
- (void)xiaoxi_zhongxin_event:(QMUIStaticTableViewCellData *)cellData {
    DLog();
    [self.tableView qmui_clearsSelection];
    XiaoxiTongzhi_vc *vc= [[XiaoxiTongzhi_vc alloc]init];
    vc.hidesBottomBarWhenPushed = YES;
    
    vc.hidesBottomBarWhenPushed = YES;
    
   
    [self.navigationController pushViewController:vc animated:YES];
}
//- (void)guanyu_women_event:(QMUIStaticTableViewCellData *)cellData{
//    DLog();
//    [self.tableView qmui_clearsSelection];
//    AboutVc *vc= [[AboutVc alloc]init];
//    vc.hidesBottomBarWhenPushed = YES;
//    [self.navigationController pushViewController:vc animated:YES];
//}
- (void)shebei_guanli_event:(QMUIStaticTableViewCellData *)cellData{
    DLog();
    [self.tableView qmui_clearsSelection];
    Shebei_guanli_vc *vc= [[Shebei_guanli_vc alloc]init];
    
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
    
    
}

- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    
    
}
- (IBAction)zhanghao_anquan:(UIButton *)sender {
    Zhanghaoanquan_vc *vc= [[Zhanghaoanquan_vc alloc]init];
    vc.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)didInitialize {
    [super didInitialize];
   
}

@end


